/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package restaurante;

import javafx.event.EventHandler;
import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;

/**
 *
 * @author 66785403
 */
public class Area extends Region {

    final DropShadow dropShadow = new DropShadow();
    public Shape shape;
    private double width, height;
    private Salon salon;

    public Area(Shape shape_) {
        this();
        shape = shape_;
        configureShape();
        this.width = ShapeFactory.CIRCLE_RADIUS * 2;
        this.height = ShapeFactory.CIRCLE_RADIUS * 2;
        
        this.getChildren().add(shape);
    }

    Area() {
        this.setId("mesa");
        dropShadow.setBlurType(BlurType.ONE_PASS_BOX);
        dropShadow.setRadius(11.0);
        //Agregar manejadores cuando se introduce en el panel?
        this.setOnMouseDragged(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent t) {
                if (salon.shapePressed) {
                }
            }
        });
//        dropShadow.setOffsetX(1.0);
//        dropShadow.setOffsetY(1.0);
    }

    protected void configureShape() {
        shape.setEffect(dropShadow);
        shape.setSmooth(true);
        shape.setStroke(Color.rgb(30, 170, 255));
        shape.setStrokeWidth(5);
        shape.setFill(null);
        shape.setStrokeType(StrokeType.INSIDE);
        shape.setStrokeLineJoin(StrokeLineJoin.ROUND);
        shape.setStrokeMiterLimit(1);
    }

    public void moveObject(double x, double y) {
        if (shape instanceof Circle) {
            this.setLayoutX(x);
            this.setLayoutY(y);
        } else if (shape instanceof Rectangle) {
            this.setLayoutX(x - ((Rectangle) shape).getWidth() / 2);
            this.setLayoutY(y - ((Rectangle) shape).getHeight() / 2);
        } else if (this instanceof AreaEle) {
            AreaEle ele = (AreaEle) this;
            ele.setLayoutX(x - ele.width / 2);
            ele.setLayoutY(y - ele.height / 2);
        }
    }

    /**
     * @return the salon
     */
    public Salon getSalon() {
        return salon;
    }

    /**
     * @param salon the salon to set
     */
    public void setSalon(Salon salon) {
        this.salon = salon;
    }

    /**
     * @return the width
     */
    public double Width() {
        return width;
    }

    /**
     * @param width the width to set
     */
    @Override
    public void setWidth(double width) {
        this.width = width;
    }

    /**
     * @return the height
     */
    public double Height() {
        return height;
    }

    /**
     * @param height the height to set
     */
    public void setHeight(double height) {
        this.height = height;
    }
}
